package com.wltt.product.frfront.config.javafx.utils;

import javafx.application.Platform;
import javafx.scene.control.Alert;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

public abstract class AlertUtil {

    public static void alert(Alert.AlertType alertType, String title, String headerText, String contentText) {
        Platform.runLater(() ->{
            Alert alert = new Alert(alertType);
            try {
                Stage stage = (Stage) alert.getDialogPane().getScene().getWindow();
                stage.getIcons().add(new Image(new ClassPathResource("icon/logo.jpg").getInputStream()));
            } catch (IOException e) {
                e.printStackTrace();
            }
            alert.setTitle(title);
            alert.setHeaderText(headerText);
            alert.setContentText(contentText);
            alert.showAndWait();
        });
    }
}
